package edu.lyun.studenttest.mapper;

import edu.lyun.studenttest.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {

    @Insert("INSERT INTO student VALUES (#{student.id},#{student.name},#{student.sex},#{student.age},#{student.birthDay},#{student.detailed})")
    int appendStudent(@Param("student") Student student);

    @Select("SELECT * FROM student")
    List<Student> getStudents();

    @Update("UPDATE student SET id=#{student.id},name=#{student.name},sex=#{student.sex},age=#{student.age},birth_day=#{student.birthDay},detailed=#{student.detailed} WHERE id=#{student.id}")
    int updateStudent(@Param("student") Student student);

    @Delete("DELETE FROM student WHERE id=#{id}")
    int deleteStudentById(@Param("id") int id);
}
